#include "iic_led_stm32.h"
#include <stdio.h>

int i2c_led_stm32_read(IicLedStm32* self, char addr, int* data)
{
    PRINT_FILE_LINE_FUNC();
    *data = self->data_in_reg;
    printf("STM32 IIC reading byte = %d\n", *data);
    return 0;
}

int i2c_led_stm32_write(IicLedStm32* self, char addr, int data)
{
    PRINT_FILE_LINE_FUNC();
    self->data_in_reg = data;
    printf("STM32 IIC writting byte = %d\n", data);
    return 0;
}

IicLed_i iic_led_stm32_interface = {
    (i2c_led_read_byte_fn_t)i2c_led_stm32_read,
    (i2c_led_write_byte_fn_t)i2c_led_stm32_write
};

int init_iic_led_stm32(IicLedStm32* self)
{
    PRINT_FILE_LINE_FUNC();
    self->interface = &iic_led_stm32_interface;
    self->iic_address = IIC_0_ADDRESS;
    self->data_in_reg = LIGHT_OFF;
    return 0;
}
